/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * 
 * Copyright 2010 yura, Version 2.0 (the "License");
 *
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 *
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * 
 * Unless required by applicable law or agreed to in writing, software
 *
 * distributed under the License is distributed on an "AS IS" BASIS,
 *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 *
 * limitations under the License.
 */
package org.opu.doc2db.document.datadocument.io;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

/**
 *  Abstract class for writing to character or byte streams
 * Document class. The only methods that a subclass must implement are:
 * write(OutputStream out) and write(Writer writer).
 *
 * @author yura
 */
public interface DocumentWriter {

    /**
     *  Writes curent document to the output stream in a format
     * declared in implamented class<br>
     *  The stream is written using the UTF-8 character encoding,
     * if implamented class, data format storing, use character sequence.<br>
     *  After the entries have been written, the output stream is flushed.
     * The output stream remains open after this method returns.
     *
     * @param out an output stream.
     * @throws IOException if writing this property list to the specified
     * output stream throws an IOException.
     * @throws NullPointerException - if out is null.
     */
    public void write(OutputStream out) throws IOException;

    /**
     *  Writes curent document to the output character stream in a
     * format declared in implamented class<br>
     *  After the entries have been written, the output stream is flushed.
     * The output stream remains open after this method returns.
     *
     * @param writer an output character stream writer.
     * @throws IOException if writing this property list to the specified
     * output stream throws an IOException.
     * @throws NullPointerException - if writer is null.
     */
    public void write(Writer writer) throws IOException;

    /**
     *  Write in file
     * @param file file where to write (must exist and can be write)
     * @throws IOException if writing this property list to the specified
     * output stream throws an IOException.
     */
    public void write(File file) throws IOException;
}
